package com.maduar.demo.thread;

/**
 * Description:
 *
 * @author maduar maduar@163.com
 * @date 2021-05-09 11:13
 */
public class TaskRunner {

    private static volatile int number;
    private static volatile boolean ready;

    private static class Reader extends Thread {
        @Override
        public void run() {
            while (!ready) {
                Thread.yield();
            }
            System.out.println(number);
        }
    }

    public static void main(String[] args) {
        new Reader().start();
        number = 42;
        ready = true;
    }

}
